load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_binary", "mongo_cc_library")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

idl_generator(
    name = "framework_options_gen",
    src = "framework_options.idl",
)

mongo_cc_library(
    name = "testframework",
    srcs = [
        "framework.cpp",
        "framework_options.cpp",
        "framework_options_gen",
        "framework_options_init.cpp",
    ],
    deps = [
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db:server_base",
        "//src/mongo/db:service_context_d",
        "//src/mongo/db/admission:flow_control_parameters",
        "//src/mongo/db/index_builds:index_builds_coordinator_mongod",
        "//src/mongo/db/op_observer",
        "//src/mongo/db/rss/attached_storage:attached_persistence_provider",
        "//src/mongo/db/s:sharding_runtime_d",
        "//src/mongo/db/shard_role/shard_catalog:catalog_impl",
        "//src/mongo/db/storage:storage_control",
        "//src/mongo/db/storage:storage_options",
        "//src/mongo/scripting:scripting_common",
        "//src/mongo/unittest",
        "//src/mongo/util:periodic_runner_factory",
        "//src/mongo/util/options_parser:options_parser_init",
    ],
)

mongo_cc_library(
    name = "mocklib",
    srcs = [
        "//src/mongo/dbtests/mock:mock_conn_registry.cpp",
        "//src/mongo/dbtests/mock:mock_dbclient_connection.cpp",
        "//src/mongo/dbtests/mock:mock_remote_db_server.cpp",
        "//src/mongo/dbtests/mock:mock_replica_set.cpp",
    ],
    deps = [
        "//src/mongo/client:clientdriver_network",
        "//src/mongo/client:dbclient_mockcursor",
        "//src/mongo/client:replica_set_monitor_test_helper",
        "//src/mongo/db:query_expressions",
        "//src/mongo/db/exec:projection_executor",
        "//src/mongo/db/pipeline:expression_context_for_test",
        "//src/mongo/db/query:query_test_service_context",
        "//src/mongo/db/query/compiler/logical_model/projection:projection_ast",
        "//src/mongo/db/repl:replica_set_messages",
    ],
)

# TODO(SERVER-96941): Remove shim once it's possible to use select in binary deps
mongo_cc_library(
    name = "deps_shim",
    deps = select({
        "//bazel/config:enterprise_feature_ldap_and_wiredtiger_enabled": [
            "//src/mongo/db/modules/enterprise/src/inmemory:storage_inmemory",
        ],
        "//conditions:default": [],
    }) + select({
        "//bazel/config:use_wiredtiger_enabled": ["//src/mongo/db/storage/wiredtiger:storage_wiredtiger"],
        "//conditions:default": [],
    }),
)

mongo_cc_binary(
    name = "dbtest",
    srcs = [
        "basictests.cpp",
        "clienttests.cpp",
        "commandtests.cpp",
        "counttests.cpp",
        "dbhelper_tests.cpp",
        "dbtests.cpp",
        "deferred_writer.cpp",
        "directclienttests.cpp",
        "documentsourcetests.cpp",
        "extended_validate_tests.cpp",
        "extensions_callback_real_test.cpp",
        "indexupdatetests.cpp",
        "insert_test.cpp",
        "jsobjtests.cpp",
        "jsontests.cpp",
        "logical_sessions_tests.cpp",
        "mock_dbclient_conn_test.cpp",
        "mock_replica_set_test.cpp",
        "pdfiletests.cpp",
        "plan_executor_invalidation_test.cpp",
        "plan_ranking.cpp",
        "query_plan_executor.cpp",
        "query_stage_and.cpp",
        "query_stage_batched_delete.cpp",
        "query_stage_cached_plan.cpp",
        "query_stage_collscan.cpp",
        "query_stage_count.cpp",
        "query_stage_count_scan.cpp",
        "query_stage_delete.cpp",
        "query_stage_distinct.cpp",
        "query_stage_fetch.cpp",
        "query_stage_ixscan.cpp",
        "query_stage_limit_skip.cpp",
        "query_stage_merge_sort.cpp",
        "query_stage_multiplan.cpp",
        "query_stage_near.cpp",
        "query_stage_sort.cpp",
        "query_stage_sort_key_generator.cpp",
        "query_stage_subplan.cpp",
        "query_stage_tests.cpp",
        "query_stage_trial.cpp",
        "query_stage_update.cpp",
        "querytests.cpp",
        "replica_set_tests.cpp",
        "repltests.cpp",
        "rollbacktests.cpp",
        "socktests.cpp",
        "storage_debug_util.cpp",
        "threadedtests.cpp",
        "updatetests.cpp",
        "validate_tests.cpp",
        "wildcard_access_method_test.cpp",
        "wildcard_multikey_persistence_test.cpp",
        "//src/mongo/db/shard_role/shard_catalog:catalogtests.cpp",
        "//src/mongo/db/shard_role/shard_catalog:indexcatalogtests.cpp",
    ],
    srcs_select = [{
        "//bazel/config:js_engine_mozjs": [
            "jstests.cpp",
            "matchertests.cpp",
        ],
        "//conditions:default": [],
    }],
    tags = ["dbtest"],
    deps = [
        "deps_shim",
        "mocklib",
        "testframework",
        "//src/mongo/bson/dotted_path:dotted_path_support",
        "//src/mongo/client:clientdriver_network",
        "//src/mongo/client:replica_set_monitor_protocol_test_util",
        "//src/mongo/db:index_key_validate",
        "//src/mongo/db:mongohasher",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:query_exec",
        "//src/mongo/db:server_base",
        "//src/mongo/db:service_context_d",
        "//src/mongo/db:traffic_reader",
        "//src/mongo/db:vector_clock",
        "//src/mongo/db:working_set_common",
        "//src/mongo/db/auth:authserver",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/commands:mongod",
        "//src/mongo/db/commands:test_commands_enabled",
        "//src/mongo/db/exec/document_value:document_value_test_util",
        "//src/mongo/db/exec/mutable_bson:mutable_bson_test_utils",
        "//src/mongo/db/index:index_access_method",
        "//src/mongo/db/index_builds:index_build_test_helpers",
        "//src/mongo/db/index_builds:multi_index_block",
        "//src/mongo/db/op_observer",
        "//src/mongo/db/op_observer:op_observer_impl",
        "//src/mongo/db/op_observer:operation_logger_impl",
        "//src/mongo/db/query:command_request_response",
        "//src/mongo/db/query:query_planner_test_lib",
        "//src/mongo/db/query:query_request",
        "//src/mongo/db/query/client_cursor",
        "//src/mongo/db/query/collation:collator_interface_mock",
        "//src/mongo/db/query/compiler/optimizer/cost_based_ranker:plan_ranking_utils",
        "//src/mongo/db/query/query_settings:query_settings_service",
        "//src/mongo/db/query/write_ops",
        "//src/mongo/db/repl:oplog_entry_test_helpers",
        "//src/mongo/db/repl:repl_coordinator_interface",
        "//src/mongo/db/repl:replication_consistency_markers_impl",
        "//src/mongo/db/repl:replication_recovery",
        "//src/mongo/db/repl:replmocks",
        "//src/mongo/db/repl:serveronly_repl",
        "//src/mongo/db/repl:storage_interface_impl",
        "//src/mongo/db/repl/dbcheck:deferred_writer",
        "//src/mongo/db/session:service_liaison_mongod",
        "//src/mongo/db/shard_role",
        "//src/mongo/db/shard_role/shard_catalog:catalog_helpers",
        "//src/mongo/db/shard_role/shard_catalog:collection_options",
        "//src/mongo/db/shard_role/shard_catalog:durable_catalog",
        "//src/mongo/db/storage:mdb_catalog",
        "//src/mongo/db/storage:sorted_data_interface_test_assert",
        "//src/mongo/db/storage:storage_engine_impl",
        "//src/mongo/db/storage:storage_options",
        "//src/mongo/db/topology/vector_clock:logical_time_metadata_hook",
        "//src/mongo/db/transaction",
        "//src/mongo/db/validate:collection_validation",
        "//src/mongo/s:sharding_router_api",
        "//src/mongo/shell:shell_utils",
        "//src/mongo/transport:message_compressor_options_server",
        "//src/mongo/transport:session_manager",
        "//src/mongo/transport:transport_layer_manager",
        "//src/mongo/util:clock_source_mock",
        "//src/mongo/util:password",
        "//src/mongo/util:processinfo",
        "//src/mongo/util:progress_meter",
        "//src/mongo/util:signal_handlers",
        "//src/mongo/util:version_impl",
        "//src/mongo/util/concurrency:ticketholder",
        "//src/mongo/util/net:network",
        "//src/mongo/util/options_parser:options_parser_init",
    ],
)
